export function formatDuration(seconds) {
  // 计算天数、小时数、分钟数和剩余的秒数
  let days = Math.floor(seconds / (3600 * 24));
  seconds %= (3600 * 24);
  let hours = Math.floor(seconds / 3600);
  seconds %= 3600;
  let minutes = Math.floor(seconds / 60);
  seconds %= 60;

  // 构建格式化后的字符串
  let result = '';
  if (days > 0) {
    result = days + 'd ';
  }
  if (hours < 10) {
    hours = '0' + hours;
  }
  if (minutes < 10) {
    minutes = '0' + minutes;
  }
  if (seconds < 10) {
    seconds = '0' + seconds;
  }

  result += hours + ':' + minutes + ':' + seconds;

  return result.trim(); // 去除字符串两端的空格
}

// 时间戳转"July 20, 2024"格式
export function formatDate(timestamp) {
  // 创建一个新的 Date 对象，传入时间戳（单位为毫秒）
  const date = new Date(timestamp);

  // 获取月份的英文全名
  const monthNames = [
      "January", "February", "March",
      "April", "May", "June", "July",
      "August", "September", "October",
      "November", "December"
  ];
  const month = monthNames[date.getMonth()]; // 从0开始计数，所以要用getMonth()

  // 获取日和年
  const day = date.getDate();
  const year = date.getFullYear();

  // 返回格式化后的字符串
  return `${month} ${day},${year}`;
}